package screen
{
	import com.greensock.TweenLite;
	import com.greensock.easing.Quart;
	
	import flash.display.BlendMode;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.net.URLLoader;
	import flash.text.TextField;
	import flash.utils.Timer;
	import flash.utils.setInterval;
	import flash.utils.setTimeout;
	
	import helper.ValueObject;
	
	import mx.utils.NameUtil;
	
	import screen.component.CamiAirplane;
	import screen.component.OtherAirplane;
	import screen.component.Popup;
	import screen.component.Tank;
	import screen.component.UI;

	
	public class CamiScreen extends UI
	{
		private const STEP:Number = 2;
		private var _bg:MovieClip;
		private var _bg_clone:MovieClip;
		public static var instance:CamiScreen;
		public function CamiScreen()
		{
			if(!instance){
				instance = this;
			}
		}
		public static function getInstance():CamiScreen{
			if(!instance){
				instance = new CamiScreen();
			}
			return instance;
		}
		public function onShow():void{
			init();
		}
		public function onHide():void{
			
		}
		private function init():void{
			_bg = ValueObject.C1_RESOURCE.getExportedAsset("bg") as MovieClip;
			_bg.x =0;
			_bg.y = 0;
			addChild(_bg);
			_bg_clone = ValueObject.C1_RESOURCE.getExportedAsset("bg") as MovieClip;
			_bg_clone.x = _bg.width;
			_bg_clone.y =0;
			addChild(_bg_clone);
			for(var i:Number=1;i<=3;i++){
				var cami_airplane:CamiAirplane = new CamiAirplane(i);
				cami_airplane.name = "CAP" + i.toString();
				addChild(cami_airplane);
			}
			setInterval(slider,30);
			
			var tank:Tank = Tank.getInstance();
			addChild(tank);
			
			var other_airplane:OtherAirplane = new OtherAirplane();
			addChild(other_airplane);
			
			var popup:Popup = Popup.getInsctance();
			addChild(popup);
			
			
		}
		private function slider():void{
			
			_bg.x -= STEP;
			_bg_clone.x -=STEP;
			if(_bg.x < -_bg.width){
				_bg.x = _bg_clone.x + _bg_clone.width;
			}else if(_bg_clone.x <-_bg_clone.width){
				_bg_clone.x = _bg.x + _bg.width;
			}
			
			
		}
		
	}	
}